#include<iostream>
using namespace std;
int n;
int main()
{
	scanf("%d", &n);
	int f = 0, s = 0;
	scanf("%d", &f);
	bool up = 0;
	n--;
	int cnt = 0;
	while (n--) {
		scanf("%d", &s);
		if (s > f) {
			up = 1;
		}
		else if (f > s) {
			if (up) {
				up = 0;
				cnt++;
			}
		}
		f = s;
	}
	cout << cnt << endl;
	return 0;
}